from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.options.global_options import AxisOpts
from pyecharts.charts import Line
from pyecharts.globals import ThemeType

x = ['餐饮','娱乐','交通','保养','衣服']
y1= [1000,500,100,5000,5000]
y2= [2000,1000,100,20,30]


bar = Bar()# 图片背景
bar.add_xaxis(xaxis_data = x)
#第一个参数是图例的名称
bar.add_yaxis(series_name = 'zhang某人',y_axis = y1)
bar.add_yaxis(series_name = 'fan某人',y_axis = y2)

#添加options
bar.set_series_opts(label_opts=opts.LabelOpts(position="right"))

bar.set_global_opts(title_opts=opts.TitleOpts(title = 'zhang某人和fan某人一月开支'))
# 调整间隔，例如设置为'10%'表示间隔为类目宽度的10%
# 调整柱状图的间隔

#生成HTML文件
bar.render('我的第一个echarts图.html')



